package com.chun.mapper;

//import com.chun.pojo.DegreeCountDTO;
import com.chun.pojo.DegreeCountDTO;
import com.chun.pojo.Student;
import com.chun.pojo.StudentCountDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StudentMapper {
    List<Student> getStudents(String name, Integer degree, Integer clazzId);

    void deleteStudentByIds(Integer[] ids);

    void addStudent(Student student);

    @Select("select * from student where id = #{id}")
    Student getStudentById(Integer id);

    void updateStudent(Student student);

    @Update("update student set violation_score = #{score} where id = #{id} ")
    void updateStudentScore(Integer id, Integer score);

//    @Select("select degree,count(*) as count from student group by degree ")
//    List<DegreeCountDTO> getStudentDegreeData();

    @Select("select degree,count(*) as count from student group by degree ")
    List<DegreeCountDTO> getStudentDegreeData();

    @Select("select clazz.name clazzName,count(*) data from clazz left join student on student.clazz_id = clazz.id group by clazzName")
    List<StudentCountDTO> getStudentCountDTOList();

}
